
<div class="circle-share">
    <form method="post" action="{:url('circle/themeshare/index')}?c_id={$c_id}&t_id={$t_id}" id="share_form" class="feededitor">
        <input type="hidden" name="form_submit" value="ok"/>
        <dl class="share-target">
            <dt class="title"><?php echo $theme_info['theme_name'];?></dt>
            <dd class="cover">
                <?php if(!empty($affix_list)){?>
                <?php foreach(($affix_list) as $val){?>
                <a href="Javascript: void(0);"><img src="<?php echo themeImageUrl($val['affix_filethumb']);?>"/></a>
                <?php }?>
                <?php }?>
            </dd>
            <dd class="sub"><span id="_share_publisher">作者：<?php echo $theme_info['member_name'];?></span><span id="_share_origin">来自：<?php echo $theme_info['circle_name'];?></span></dd>
            <dd class="abstract"><?php echo removeUBBTag($theme_info['theme_content']);?></dd>
        </dl>
        <!-- 站外分享 -->
        <?php if (sysconf('share_isuse') == 1 && !empty($app_arr)){?>
        <div class="share-widget"> <span class="title">同时分享到：</span> <span class="s-app">
      <?php foreach ($app_arr as $k=>$v){?>
      <label nc_type="appitem_<?php echo $k;?>" title="<?php echo $v['name'];?>" class="<?php echo $v['isbind']?'checked':'disable';?>"> <i class="i-<?php echo $k;?>" nc_type="bindbtn" data-param='{"apikey":"<?php echo $k;?>","apiname":"<?php echo $v['name'];?>"}' attr_isbind="<?php echo $v['isbind']?'1':'0';?>"></i>
          <input type="hidden" id="checkapp_<?php echo $k;?>" name="checkapp_<?php echo $k;?>" value="<?php echo $v['isbind']?'1':'0';?>" />
      </label>
            <?php }?>
            <a target="_blank" href="<?php echo url('member/sharemanage/index');?>">同步设置</a> </span> </div>
        <?php }?>
        <div class="share-content">
            <textarea placeholder="跟大家一起分享自己喜欢的宝贝吧~" name="content" id="content_sgweibo" resize="none"></textarea>
        </div>
        <input type="text" style="display:none;" />
        <!-- 防止点击Enter键提交 -->
        <div class="handle">
            <div id="sgcharcount" class="count"></div>
            <div class="error form-error"></div>
            <input name="分享" type="button" class="button" value="分享" id="share_button" />
        </div>
        <input type="hidden" name="gprivacy" id="gprivacy" value="0"/>
    </form>
</div>
<textarea id="bindtooltip_module" style="display:none;">
<div class="eject_con"><dl><dt style="width:25%"><img src="__CIRCLE_TEMPLATES_URL__/images/shareicon/shareicon_@apikey.png" width="40" height="40" class="mt5 mr20"></dt><dd style="width:75%"><p>即将前往<strong class="ml5 mr5">@apiname</strong>连接账号，我们确保你的<br>账号安全，请放心连接...</p><p class="red">长时间不分享给@apiname，绑定会失效哦</p></dd></dl>
    <dl class="bottom"><dt style="width:25%">&nbsp;</dt>
        <dd style="width:75%"><a href="javascript:void(0);" nc_type="finishbtn" data-param='{"apikey":"@apikey"}' class="ncu-btn2 mr10">完成连接</a><span>完成连接<a target="_blank" href="<?php echo MEMBER_SITE_URL;?>/api.php?act=sharebind&type=@apikey" class="ml5">重新连接</a></span></dd>
    </dl>
</div>
</textarea>
<script type="text/javascript">
    var max_recordnum = '<?php echo $max_recordnum;?>';
    $(function(){
        $(".thumb-cut .t-img").VMiddleImg({"width":100,"height":100});

        // Char Count
        $.getScript("__SITE_RESOURCE__/js/jquery.charCount.js" ,function(){
            $("#content_sgweibo").charCount({
                allowed: 140,
                warning: 10,
                counterContainerID:'sgcharcount',
                firstCounterText:'还可以输入',
                endCounterText:'字',
                errorCounterText:'已经超出'
            });
        });
        // form validate
        $('#share_form').validate({
            errorPlacement: function(error, element){
                $('.form-error').append(error);
            },
            rules : {
                content : {
                    maxlength : 140
                }
            },
            messages : {
                content : {
                    maxlength: '内容不能超过140个字符'
                }
            }
        });
        $("[nc_type='bindbtn']").bind('click',function(){
            var data_str = $(this).attr('data-param');
            eval( "data_str = "+data_str);
            // Determine whether the binding
            var isbind = $(this).attr('attr_isbind');
            if(isbind == '1'){
            	// Is binding
                if($("#checkapp_"+data_str.apikey).val() == '1'){
                    $("[nc_type='appitem_"+data_str.apikey+"']").removeClass('checked');
                    $("[nc_type='appitem_"+data_str.apikey+"']").addClass('disable');
                    $("#checkapp_"+data_str.apikey).val('0');
                }else{
                    $("[nc_type='appitem_"+data_str.apikey+"']").removeClass('disable');
                    $("[nc_type='appitem_"+data_str.apikey+"']").addClass('checked');
                    $("#checkapp_"+data_str.apikey).val('1');
                }
            }else{
                var html = $("#bindtooltip_module").text();
                // replace keywords
                html = html.replace(/@apikey/g,data_str.apikey);
                html = html.replace(/@apiname/g,data_str.apiname);
                html_form("bindtooltip", "账号连接", html, 360, 0);
                window.open(MEMBER_SITE_URL+'/api.php?act=sharebind&type='+data_str.apikey);
            }
        });
        $("[nc_type='finishbtn']").live('click',function(){
            var data_str = $(this).attr('data-param');
            eval( "data_str = "+data_str);
            // check binding
            var url = "<?php echo url('circle/share/checkbind');?>";
            $.getJSON(url, {'k':data_str.apikey}, function(data){
                DialogManager.close('bindtooltip');
                if (data.done)
                {
                    $("[nc_type='appitem_"+data_str.apikey+"']").addClass('check');
                    $("[nc_type='appitem_"+data_str.apikey+"']").removeClass('disable');
                    $('#checkapp_'+data_str.apikey).val('1');
                    $("[nc_type='appitem_"+data_str.apikey+"']").find('i').attr('attr_isbind','1');
                }
                else
                {
                    showDialog(data.msg, 'notice');
                }
            });
        });

        $("#share_button").click(function(){
            if($("#share_form").valid()){
                ajaxpost('share_form', '', '', 'onerror');
            }
        });
    });
</script>